Source File
utils.go
Belonging Package
github.com/Nerzal/gocloak/v13
package gocloak
import (
)
type contextKey string
var tracerContextKey = contextKey("tracer")
// StringP returns a pointer of a string variable
func ( string) *string {
return &
}
// PString returns a string value from a pointer
func ( *string) string {
if == nil {
return ""
}
return *
}
// BoolP returns a pointer of a boolean variable
func ( bool) *bool {
return &
}
// PBool returns a boolean value from a pointer
func ( *bool) bool {
if == nil {
return false
}
return *
}
// IntP returns a pointer of an integer variable
func ( int) *int {
return &
}
// Int32P returns a pointer of an int32 variable
func ( int32) *int32 {
return &
}
// Int64P returns a pointer of an int64 variable
func ( int64) *int64 {
return &
}
// PInt returns an integer value from a pointer
func ( *int) int {
if == nil {
return 0
}
return *
}
// PInt32 returns an int32 value from a pointer
func ( *int32) int32 {
if == nil {
return 0
}
return *
}
// PInt64 returns an int64 value from a pointer
func ( *int64) int64 {
if == nil {
return 0
}
return *
}
// Float32P returns a pointer of a float32 variable
func ( float32) *float32 {
return &
}
// Float64P returns a pointer of a float64 variable
func ( float64) *float64 {
return &
}
// PFloat32 returns an flaot32 value from a pointer
func ( *float32) float32 {
if == nil {
return 0
}
return *
}
// PFloat64 returns an flaot64 value from a pointer
func ( *float64) float64 {
if == nil {
return 0
}
return *
}
// NilOrEmpty returns true if string is empty or has a nil value
func ( *string) bool {
return == nil || len(*) == 0
}
// NilOrEmptyArray returns true if string is empty or has a nil value
func ( *[]string) bool {
if == nil || len(*) == 0 {
return true
}
return (*)[0] == ""
}
// DecisionStrategyP returns a pointer for a DecisionStrategy value
func ( DecisionStrategy) *DecisionStrategy {
return &
}
// LogicP returns a pointer for a Logic value
func ( Logic) *Logic {
return &
}
// PolicyEnforcementModeP returns a pointer for a PolicyEnforcementMode value
func ( PolicyEnforcementMode) *PolicyEnforcementMode {
return &
}
// PStringSlice converts a pointer to []string or returns ampty slice if nill value
func ( *[]string) []string {
if == nil {
return []string{}
}
return *
}
// NilOrEmptySlice returns true if list is empty or has a nil value
func ( *[]string) bool {
return == nil || len(*) == 0
}
// WithTracer generates a context that has a tracer attached
func ( context.Context, opentracing.Tracer) context.Context {
return context.WithValue(, tracerContextKey, )
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |